var event = require('events')

// 参数的默认值
function greed (x = 'Hello', y = 'node') {
  console.log(x, y)
  // let x = 'hello'//SyntaxError:Identifier 'x' has already been declared
  var x = 'hello' // 正常运行
}
greed() 

// 匿名函数当中的this
var obj = {}
obj.fun = function() {
  (function() {
    console.log(this)
  })()
}

obj.fun() // global
obj.fun2 = function () {
  (() => {
    console.log(this)
  })()
}
obj.fun2() // obj


class Producer extends event {
  constructor () {
    super()
    this.status = 'ready'
  }
}
var produ = new Producer()
produ.on('begin', function () {
  console.log(this.status) // ready
})
produ.on('begin', () => {
  console.log(this.status) //{}
})
produ.emit('begin')


